{% macro render_user_table(users, class='') %}
<table class='{{ class }}'>
    <thead>
        <tr>
            <td>#</td>
            <td>Username</td>
            <td>Email</td>
        </tr>
    </thead>
    <tbody>
        {% for user in users %}
        <tr>
            <td>{{ loop.index }}</td>
            <td><a href="{{ url_for('user.profile', name=user.name) }}">{{ user.name }}</a></td>
            <td>{{ user.email }}</td>
        </tr>
        {% endfor %}
    </tbody>
</table>
{% endmacro %}

{% macro render_pagination(pagination, endpoint) %}
    {% if pagination.pages > 1 %}
        <div class='pagination'>
            <ul>
                <li class="prev {% if not pagination.has_prev %}disabled{% endif %}"><a href="{{ url_for(endpoint, page=pagination.page-1) }}">&larr; Previous</a></li>
                {% for page in pagination.iter_pages() %}
                    {% if page %}
                        <li class='{% if page == pagination.page %}active{% endif %}'>
                            <a href='{{ url_for(endpoint, page=page) }}'>{{ page }}</a>
                        </li>
                    {% else %}
                        <li>
                            <a href='#'>...</a>
                        </li>
                    {% endif %}
                {% endfor %}
                <li class="next {% if not pagination.has_next %}disabled{% endif %}"><a href="{{ url_for(endpoint, page=pagination.page+1) }}">Next &rarr;</a></li>
            </ul>
        </div>
    {% endif %}
{% endmacro %}
